﻿using System.Data.Entity.ModelConfiguration;

namespace wh40klbModel.ModelConfiguration
{
    class VehiculeConfiguration : EntityTypeConfiguration<Vehicule>
    {
        public VehiculeConfiguration()
        {
            //Cle Primaire et table
            HasKey(v => v.Id);
            //Propriete
            Property(v => v.Name).IsRequired();
            Property(v => v.Name).HasMaxLength(25);
            Property(v => v.BallisticSkill).IsRequired();
            Property(v => v.ArmorFront).IsRequired();
            Property(v => v.ArmorRear).IsRequired();
            Property(v => v.ArmorSide).IsRequired();
            Property(v => v.description).IsOptional();
            Property(v => v.description).HasMaxLength(1000);
            //cle etrangere
            HasRequired(v => v.Army).WithMany(a => a.Vehicules);
            HasMany(v => v.TypeVehicules).WithMany(tv => tv.Vehicules);
            HasMany(v => v.Squads).WithRequired(sti => sti.Vehicule);
            ////Mapping special
            //Map(v =>
            //{
            //    v.Requires("IsWalker").HasValue(false);
            //    v.Requires("IsTransporter").HasValue(false);

            //}).Map<Walker>(w =>
            //{
            //    w.Requires("IsWalker").HasValue(true);
            //    w.Requires("IsTransporter").HasValue(false);
            //}).Map<Transporter>(t =>
            //{
            //    t.Requires("IsTransporter").HasValue(true);
            //    t.Requires("IsWalker").HasValue(false);
            //})
            //;

        }
    }
}
